package com.ds.lens.data.service;

import com.ds.lens.data.service.dao.LensMonitorChannelDao;
import com.ds.lens.data.service.dao.entity.LensMonitorChannel;
import com.ds.lens.data.vo.in.v2.monitor.LensMonitorChannelInVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author WeiShaoying
 * @date 2019/11/25 下午2:25
 */
@Service
public class LensMonitorChannelService {

    @Autowired
    LensMonitorChannelDao lensMonitorChannelDao;

    public boolean save(LensMonitorChannelInVO channelInVO) {
        LensMonitorChannel lensMonitorChannel = new LensMonitorChannel();
        BeanUtils.copyProperties(channelInVO, lensMonitorChannel);
        lensMonitorChannel.setType(channelInVO.getType().getValue());
        lensMonitorChannelDao.insertOrUpdate(lensMonitorChannel);
        return true;
    }

    public LensMonitorChannel get(Long monitorId, Integer version, String target, Integer type) {
        return lensMonitorChannelDao.selectByMonitor(monitorId, version, target, type);
    }
}
